<template>
  <div class="Gauge-container">
    <el-card>
      <div id="Gauge" :style="{width: width, height: height}"></div>
    </el-card>
  </div>
</template>

<script>
import * as echarts from 'echarts'

export default {
  name: 'Gauge',
  props:{
    height:{
      type: String,
      default: '200px'
    },
    width:{
      type: String,
      default: '200px'
    }
  },
  mounted () {
    this.$nextTick(() =>{
      this.initCharts()
    })
  },
  methods: {
    initCharts(){
      const charts = echarts.init(document.getElementById('Gauge'))
      const option = {
        title:{
          text: '仪表盘',
          textStyle:{
            fontWeight: 400,
          }
        },
        tooltip: {
          formatter: '{a} <br/>{b} : {c}%'
        },
        series: [
          {
            name: 'Pressure',
            type: 'gauge',
            detail: {
              formatter: '{value}'
            },
            data: [
              {
                value: 50,
                name: 'SCORE'
              }
            ]
          }
        ]
      };
      charts.setOption(option);
    },
  }
}
</script>

<style scoped>

</style>
